var arr = [4,5,7,216,2,6,35];
//实现map函数
var arr1 = arr.map(function(item,index)
{
    return item
})
console.log(arr,'arr');
// console.log(arr1,'arr1');


//实现filter函数
var arr2 = arr.filter(function(item,index)
{
    return item>5
})
// console.log(arr,'arr');
console.log(arr2,'arr2');

//实现findIndex函数
var arr3 = arr.findIndex(function(item,index)
{
    return item>2
})
// console.log(arr3,'arr3');

//实现find函数
var arr4 = arr.find(function(item,index)
{
    return item>100
})
// console.log(arr4,'arr4');

//实现数据扁平化flat
var brr = [1,2,3,[4,5,6,[7,[8]]]];
var newArr = brr.flat(Infinity);
console.log(newArr,'newArr');

//实现数组去重
var brr1 = [1,2,3,1,2,4];
// var arr5 = new Set(brr1);
// console.log(arr5,'arr5');

function chong(brr1)
{
    for (var i = 0; i < brr1.length; i++) 
    {
        for (var j = i + 1 ; j < brr1.length; j++) 
        {
            if(brr1[i]==brr1[j])
            {
                brr1.splice(j,1);
                j--;
            }
        }
    }
    return brr1;
}
console.log(chong(brr1),'brr1');